﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Course.Controllers
{
    [HandleError]
    public class BaseController : Controller
    {
        //
        // GET: /Base/


        /// <summary>
        /// 弹信息窗口
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public ActionResult Message(string message)
        {
            string result = "<script>alert('" + message + "')</script>";

            return Content(result);
        }

        /// <summary>
        /// 弹信息窗口半跳转
        /// </summary>
        /// <param name="message"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public ActionResult MessageRedirect(string message,string url)
        {
            string result = "<script>alert('" + message + "');window.location.href='" + url + "';</script>";

            return Content(result);
        }

        /// <summary>
        /// 弹信息窗口并回跳
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public ActionResult MessageBack(string message)
        {
            string result = "<script>alert('" + message + "');window.history.back(-1);</script>";

            return Content(result);
        }

        /// <summary>
        /// 判决是否登陆
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginSuccess()
        {
            if(Session["UserID"] != null)
            {
                return null;
            }
            else
            {
                return Content("<script>alert('用户名或密码错误!');window.location.href='/BackGround/Login';</script>");
            }
        }

    }
}
